#include				"EventZone.hpp"
#include				<iostream>

EventZone::EventZone(sf::RenderWindow &window, float x, float y, float width, float height, float thickness, sf::Color fillColor, sf::Color outColor)
	: _window(window), _x(x), _y(y), _width(width), _height(height), _thickness(thickness), _fillColor(fillColor), _outColor(outColor),
	  _zoneRect(new sf::Rect<float>(_x, _y, _width, _height)), _graphicRect(sf::RectangleShape(sf::Vector2f(_width, _height))),
	  _selectedZone(false), _onZone(false)
{
	_graphicRect.setPosition(sf::Vector2f(_x, _y));
	_graphicRect.setFillColor(_fillColor);
	_graphicRect.setOutlineThickness(_thickness);
	_graphicRect.setOutlineColor(_outColor);
}

EventZone::~EventZone()
{
}

void					EventZone::draw()
{
	if (_onZone || _selectedZone)
		_window.draw(_graphicRect);
}

bool					EventZone::clickedOnZone()
{
	if (_onZone)
	{
		if (_selectedZone)
			_selectedZone = false;
		else
			_selectedZone = true;
		return (true);
	}
	return (false);
}

void					EventZone::mouseOnZone(float x, float y)
{
	if (_zoneRect->contains(x, y))
		_onZone = true;
	else
		_onZone = false;
}

bool			const	EventZone::getSelected() const
{
	return (_selectedZone);
}